home *** CD-ROM | disk | FTP | other *** search
/ Amoszine 10 / Amoszine 10 (Disk 3 of 3).adf / Amos_Procs.lha / BOB_Squisher.AMOS / BOB_Squisher.amosSourceCode
Encoding:
AMOS Source Code  |  1991-12-03  |  3.0 KB  |  127 lines

  1. ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  2. '                          Dynamic Bob Squisher  
  3. '        (packs and then squashes for compression of up to 90%)
  4. '
  5. '                            By P.J.Hickman
  6. '          (using routines from Francois Lionet & Gary Symons) 
  7. '
  8. '          This code is (c) Copyright 1991 Europress Software
  9. '
  10. ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  11. Screen Open 0,640,200,2,Hires
  12. Flash Off 
  13. Curs Off 
  14. Palette $0,$FFF
  15. '
  16. For LOP=1 To 16
  17.    Erase LOP
  18. Next LOP
  19. '
  20. F$=Fsel$("*.Abk","","Enter sprite bank to load")
  21. If F$=""
  22.    End 
  23. End If 
  24. Load F$
  25. If Length(1)=0
  26.    Edit 
  27. End If 
  28. '
  29. MXSPR=Length(1)
  30. Print "Number of bobs: ";MXSPR
  31. STSPR=1
  32. ENSPR=MXSPR
  33. Repeat 
  34.    Input "Number of colours? ";NCOL
  35.    NPLANE=1 : C=2
  36.    While C<>NCOL and NPLANE<7
  37.       Inc NPLANE : C=C*2
  38.    Wend 
  39. Until NPLANE<7
  40. '
  41. BNUMB=15
  42. Repeat 
  43.    BWORK=Rnd(8)+6
  44. Until BWORK<>BNUMB
  45. '
  46. Screen Open 0,320,200,NCOL,0
  47. Flash Off : Get Sprite Palette 
  48. Paper 0 : Pen 1 : Clw : BIGX=0 : BIGY=0
  49. '
  50. For N=1 To MXSPR
  51.    If N>=STSPR and N<=ENSPR
  52.       Cls 0,0,0 To 320,100
  53.       A=Sprite Base(N)
  54.       SX=Deek(A)*16 : SY=Deek(A+2)
  55.       ICOL=Deek(A+4)
  56.       If ICOL<>0
  57.          Paste Bob 0,0,N
  58.          Erase BWORK : Pack 0 To BWORK,0,0,SX,SY
  59.          Add PSIZE,Length(BWORK)
  60.          Add NSIZE,((SX*SY)/8)*NPLANE
  61.          Print At(0,24);"Normal size";NSIZE;" / Packed size";PSIZE;
  62.          If SX>BIGX
  63.             BIGX=SX
  64.          End If 
  65.          If SY>BIGY
  66.             BIGY=SY
  67.          End If 
  68.       End If 
  69.    End If 
  70. Next 
  71. '
  72. Reserve As Data BNUMB,PSIZE+MXSPR*10+4
  73. APACK=Start(BNUMB)+MXSPR*10
  74. Clw : Centre At(,24)+"...Final size:"+Str$(PSIZE+MXSPR*10+4)+" ("+Str$(NSIZE)+" )..."
  75. OLDSIZE=PSIZE+MXSPR*10+4
  76. '
  77. For N=1 To MXSPR
  78.    If N>=STSPR and N<=ENSPR
  79.       Cls 0,0,0 To 320,100
  80.       A=Sprite Base(N)
  81.       SX=Deek(A)*16 : SY=Deek(A+2)
  82.       ICOL=Deek(A+4)
  83.       If ICOL<>0
  84.          Paste Bob 0,0,N
  85.          Erase BWORK : Pack 0 To BWORK,0,0,SX,SY
  86.          AOFF=Start(BNUMB)+(N-1)*10
  87.          Doke AOFF,(APACK-Start(BNUMB))/2
  88.          Loke AOFF+2,Leek(A) : Loke AOFF+6,Leek(A+6)
  89.          Copy Start(BWORK),Start(BWORK)+Length(BWORK) To APACK
  90.          Add APACK,Length(BWORK)
  91.       End If 
  92.    End If 
  93. Next 
  94. '
  95. '
  96. Screen Open 0,640,200,2,Hires
  97. Flash Off 
  98. Curs Off 
  99. Palette $0,$FFF
  100. Print "Please wait, I am now squashing bank....."
  101. View 
  102. L= Extension_5_00CE(Start(BNUMB),Length(BNUMB),-1,512,17)
  103. Print "The bank is now fully squished!!!"
  104. Print "It is actually now only";L;" bytes long!!"
  105. Print "(The original was";NSIZE;" bytes)"
  106. Print 
  107. Print "Please remember these numbers:-"
  108. Print "1]";OLDSIZE
  109. Print "2]";L
  110. Print "3]";NCOL
  111. Print 
  112. Print "Both of these numbers are needed when you unsquish your sprites!!"
  113. Print "Please write them down!!!!!!"
  114. Print 
  115. Print "PRESS A KEY TO SAVE THE SQUASHED SPRITES"
  116. Wait Key 
  117. F$=Fsel$("*.Squished","","Please enter saved bank name...")
  118. If F$<>""
  119.    If Upper$(Right$(F$,9))<>".SQUISHED"
  120.       F$=F$+".Squished"
  121.    End If 
  122.    Bsave F$,Start(BNUMB) To Start(BNUMB)+L
  123. End If 
  124. '
  125. For LOP=1 To 16
  126.    Erase LOP
  127. Next LOP